package cn.mumzone.pos.util;

import android.hardware.Camera;

import cn.mumzone.pos.AppConstants;
import cn.mumzone.pos.BuildConfig;
import cn.mumzone.pos.model.source.AppRepository;

/**
 * Created by qiuzhenhuan on 2019/7/12.
 */

public class AppUtil {

    /**
     * 判断App版本是否为商米版
     *
     * @return
     */
    public static boolean isAppSunMiVersion() {
        return BuildConfig.FLAVOR.equals("sunmibeta") || BuildConfig.FLAVOR.equals("sunmipre") || BuildConfig.FLAVOR.equals("sunmipro");
    }


    /**
     * 判断当前pos机是否为宝盈设备
     *
     * @return
     */
    public static boolean isBaoYingPos() {
        return "BY".equals(AppConstants.TEMP_EQUI_MODEL);
    }


    /**
     * 判断当前pos机是否为商米设备
     *
     * @return
     */
    public static boolean isSunMiPos() {
        return "D1".equals(AppConstants.TEMP_EQUI_MODEL) || "D2".equals(AppConstants.TEMP_EQUI_MODEL);
    }


    /**
     * 是否为扫脸支付型号
     */
    public static boolean isFacePayPos() {
        return "D2".equals(AppConstants.TEMP_EQUI_MODEL) && Camera.getNumberOfCameras() > 0;
    }

    /**
     * 判断是否存在更新
     *
     * @return
     */
    public static boolean isNeedUpdate() {
        AppRepository repository = new AppRepository();
        return !BuildConfig.VERSION_NAME.equals(repository.getRemoteVersion());
    }


    public static boolean isOnlyHasGoodsBusiness() {
        return hasGoodsBusiness() && !hasServiceBusiness() && !hasBabySwimBusiness();
    }

    public static boolean hasGoodsBusiness() {
        return AppConstants.TEMP_BUSINESS_SCOPE.contains("0");
    }


    public static boolean hasServiceBusiness() {
        return AppConstants.TEMP_BUSINESS_SCOPE.contains("1");
    }


    public static boolean hasBabySwimBusiness() {
        return AppConstants.TEMP_BUSINESS_SCOPE.contains("2");
    }
}
